package swingTest;

import cn.dragon.eatingfish.Images;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class PrintMenu extends JFrame{

    public static void main(String[] args) throws AWTException {
        JFrame jf = new JFrame("大鱼吃小鱼");
        jf.setSize(1400, 700);
        jf.setLocationRelativeTo(null);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

        JPanel panel = new JPanel();



        final JButton btn = new JButton();

        btn.setSize(200,78);
        // 设置按钮的默认图片
        btn.setIcon(new ImageIcon("images/1.png"));

        // 设置按钮被点击时的图片
        btn.setPressedIcon(new ImageIcon("images/2.png"));

        // 不绘制边框
        btn.setBorderPainted(false);
        btn.setContentAreaFilled(false);    //不绘制默认按钮背景
        btn.setFocusPainted(false);           //不绘制图片或文字周围的焦点虚框
        // 添加按钮点击事件监听器
        btn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("按钮被点击了");
            }
        });

        panel.add(btn);

        jf.setContentPane(panel);
        jf.setVisible(true);
    }

}
